package com.carkeeper.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.carkeeper.pojo.ServicePO;
import org.apache.ibatis.annotations.*;

/**
 * @author: dongxing
 * @date ：Created in 2020/5/25
 * @description ：服务项mapper
 * @version: 1.0
 */
@Mapper
public interface ServiceMapper extends BaseMapper<ServicePO> {

    /**
     * 级联查询服务项关联的 一级分类 二级分类 商家信息
     *
     * @param id
     * @return
     */
    @Results(id = "serviceMapper", value = {
            @Result(property = "serviceTypePo", column = "service_type_id", one = @One(select =
                    "com.carkeeper.mapper.ServiceTypeMapper.selectById")),
            @Result(property = "serviceSubTypePo", column = "service_sub_type_id", one = @One(select =
                    "com.carkeeper.mapper.ServiceSubtypeMapper.selectById")),
            @Result(property = "storePo", column = "store_id", one = @One(select =
                    "com.carkeeper.mapper.StoreMapper.selectById")),
            @Result(property = "serviceSubTypeId", column = "service_sub_type_id"),
            @Result(property = "serviceTypeId", column = "service_type_id"),
    })
    @Select("select * from tb_service where id=#{id}")
    ServicePO findServiceById(Long id);
}